// tabs
import { renderStart } from '@/model/type'
import { getBaseData } from '@/utils/store'
export const OPERATE_TAB = [
  {
    value: 'dataInfo',
    label: '概况信息'
  },
  {
    value: 'saleInfo',
    label: '销售单记录'
  },
  {
    value: 'outstandPlanInfo',
    label: '回款计划'
  },
  {
    value: 'outstandInfo',
    label: '回款记录'
  },
  {
    value: 'invoiceInfo',
    label: '发票记录'
  },
  {
    value: 'followUpInfo',
    label: '跟进记录'
  },
  {
    value: 'belongInfo',
    label: '归属记录'
  },
  {
    value: 'operatInfo',
    label: '操作日志'
  }
]

// dataInfo module
export const base = info => {
  return [
    { name: '客户名称', label: 'customerName' },
    { name: '客户ID', label: 'id' },
    { name: '客户类型', label: 'customerTypeName' },
    {
      name: '最低销售金额阈值',
      // label: 'rental'
      render: (h, res) => {
        return <div>￥{info.form.rental}</div>
      }
    },
    { name: '所属行业', label: 'tradeTypeName' },
    {
      name: '客户级别',
      // label: 'customerStar',
      render: (h, res) => {
        return (
          <div class="text-warning fs16">
            {renderStart(info.form.customerStar)}
          </div>
        )
      }
    },
    { name: '客户来源', label: 'customerSourceName' },
    { name: '报备项目', label: 'reportProject' },
    { name: '采购时间', label: 'purchaseDate' }
  ]
}

export const link = info => {
  return [
    { name: '对接人', label: 'linkMan' },
    { name: '职务', label: 'career' },
    { name: '手机号码', label: 'mobile' },
    { name: '固定电话', label: 'fixedMobile' },
    { name: '电子邮箱', label: 'email' },
    { name: '微信号', label: 'wechat' }
  ]
}

export const additional = info => {
  return [
    { name: '所在地区', label: 'regionName' },
    { name: '详细地址', label: 'address' },
    { name: '归属公司', label: 'belongCompany' },
    { name: '开票主体', label: 'invoiceCompany' },
    /* render: (h, res) => {
        return [
          <div class="button-group">
            <span>{info.form.invoiceCompany}</span>
            <a
              href="javasript:;"
              class="text-primary pl10"
              onClick={() => info.onDetail(res)}
            >
              详情
            </a>
          </div>
        ]
      }
    }, */
    { name: '企业规模', label: 'companyScaleName' },
    { name: '备注信息', label: 'additionalInformation' },
    { name: '纳税人识别号', label: 'taxCode' }
  ]
}

export const belong = info => {
  return [
    { name: '所属业务员', label: 'belongName' },
    { name: '所属部门', label: 'belongDepartName' },
    { name: '前所属业务员', label: 'beforeBelongName' },
    { name: '前所属部门', label: 'beforeBelongDepartName' },
    { name: '创建时间', label: 'createTime' },
    { name: '更新时间', label: 'updateTime' }
  ]
}

// 销售单记录
export const saleColumns = ctx => {
  return [
    {
      prop: 'orderNo',
      label: '销售单号'
    },

    {
      prop: 'name',
      label: '销售单名称'
    },

    {
      prop: 'statusName',
      label: '订单状态'
    },
    {
      prop: 'payStatusName',
      label: '回款状态'
    },
    {
      prop: 'saleTotalPrice',
      label: '销售总额(元)'
    },
    {
      prop: 'refundTotalPrice',
      label: '退款总额(元)'
    },
    {
      prop: 'actualSaleTotalPrice',
      label: '实际销售总额(元)'
    },
    {
      prop: 'payMoney',
      label: '已回款总额(元)'
    },
    {
      prop: 'proportionPrice',
      label: '预估绩效提成'
    },
    {
      prop: 'actualProportionPrice',
      label: '实际绩效提成'
    },
    {
      prop: 'payDate',
      label: '计划回款日期'
    },
    {
      prop: 'overdueDays',
      label: '逾期天数(天)'
    }
  ]
}

// 跟进记录
export const followUpColumns = ctx => {
  return [
    {
      prop: 'customerName',
      label: '状态',
      render: (h, row) => {
        const notyet = (
          <div>
            <div class="text-error fs16">● 未查阅</div>
          </div>
        )
        const already = <div class="text-success">● 已查阅</div>
        return row.isConsulted === '1' ? [already] : [notyet]
      }
    },

    {
      prop: 'customerName',
      label: '客户名称'
    },

    {
      prop: 'tradeType',
      label: '客户行业'
    },
    {
      prop: 'customerStatus',
      label: '客户状态'
    },
    {
      prop: 'followAccountName',
      label: '跟进人员'
    },
    {
      prop: 'followType',
      label: '跟进方式'
    },
    {
      prop: 'followTime',
      label: '跟进时间'
    },
    {
      prop: 'hoverContent',
      label: '内容',
      width: 300,
      toolTip: true
    }
  ]
}

// 操作日志
export const operatColumns = ctx => {
  return [
    {
      prop: 'createTime',
      label: '操作时间'
    },

    {
      prop: 'realName',
      label: '操作人员'
    },
    {
      prop: 'logType',
      label: '操作类型'
    },
    {
      prop: 'customerName',
      label: '客户名称'
    },
    {
      prop: 'customerType',
      label: '客户类型'
    },
    {
      prop: 'remark',
      label: '备注'
    }
  ]
}

// 归属记录
export const belongColumns = ctx => {
  return [
    {
      prop: 'createTime',
      label: '操作时间'
    },

    {
      prop: 'nowAccountName',
      label: '目前归属'
    },
    {
      prop: 'beforeAccountName',
      label: '原来归属'
    },
    {
      prop: 'accountName',
      label: '操作人'
    },
    {
      prop: 'transferType',
      label: '变更类型'
    },
    {
      prop: 'remark',
      label: '备注'
    }
  ]
}

// 回款计划
export const outstandPlanColumns = ctx => {
  return [
    {
      prop: 'planOrderNo',
      label: '回款计划编号'
    },
    {
      // prop: 'status',
      label: '订单状态',
      render: (h, row) => {
        let list = getBaseData()
        let res = list.orderStatus.find(item => {
          return item.value === row.status
        })
        switch (res.value) {
          case '1':
            res.style = 'success'
            break
          case '2':
            res.style = 'primary'
            break
          case '3':
            res.style = 'warning'
            break
          case '4':
            res.style = 'danger'
            break
          default:
            res.style = 'primary'
            break
        }
        return [
          <el-tag type={res.style} size="mini">
            {res.name}
          </el-tag>
        ]
      }
    },
    {
      // prop: 'payStatus',
      label: '回款状态',
      render: (h, row) => {
        const list = getBaseData()
        let res = list.payStatus.find(item => {
          return item.value === row.payStatus
        })
        switch (res.value) {
          case '1':
            res.style = 'warning'
            break
          case '2':
            res.style = 'primary'
            break
          case '3':
            res.style = 'success'
            break
          case '4':
            res.style = 'danger'
            break
          default:
            res.style = 'primary'
            break
        }
        return [
          <el-tag type={res.style} size="mini">
            {res.name}
          </el-tag>
        ]
      }
    },
    {
      prop: 'orderNo',
      label: '销售单号'
    },
    {
      prop: 'saleName',
      label: '销售单名称'
      /*  render: (h, row) => {
        return [
          <el-button
            type="text"
            onClick={() => {
              ctx.onShowSale(row)
            }}
          >
            {row.saleName}
          </el-button>
        ]
      } */
    },
    {
      prop: 'salesmanName',
      label: '归属业务员'
    },
    {
      prop: 'saleTotalPrice',
      label: '销售总额(元)'
    },
    {
      prop: 'refundTotalPrice',
      label: '退款金额(元)'
    },
    {
      prop: 'actualReceivable',
      label: '实际应收(元)'
    },
    {
      prop: 'yetReturnedMoney',
      label: '已回款总额(元)'
    },
    {
      prop: 'residue',
      label: '剩余应收（元）'
    },
    {
      prop: 'overdueDay',
      label: '逾期天数(天)'
    },
    {
      prop: 'planReturnedTime',
      label: '计划回款日期'
    }
  ]
}

// 回款记录
export const outstandColumns = ctx => {
  return [
    {
      prop: 'returnedNo',
      label: '回款编号',
      minWidth: 120
    },
    {
      prop: 'returnedTime',
      label: '回款日期'
    },
    {
      prop: 'returnedTypeName',
      label: '入账类型'
    },
    {
      prop: 'operator',
      label: '回款操作人'
    },
    {
      prop: 'salesmanName',
      label: '回款所属业务员',
      minWidth: 140
    },
    {
      // prop: 'returnedPeriods',
      label: '回款期次',
      render: (h, row) => {
        return [<span>第{row.returnedPeriods}期</span>]
      }
    },

    {
      prop: 'returnedMoney',
      label: '回款金额(元)'
    },
    // {
    //   prop: 'balanceAmount',
    //   label: '红冲金额(元)'
    // },
    {
      prop: 'gatheringName',
      label: '收款单位'
    },
    {
      prop: 'transactionNo',
      label: '交易流水号'
    },
    {
      prop: 'overdueStatus',
      label: '逾期状态',
      render: (h, row) => {
        const style =
          row.overdueStatus === '1'
            ? 'success'
            : row.overdueStatus === '2'
              ? 'danger'
              : ''
        return <el-tag type={style} size="mini">{row.overdueStatusName}</el-tag>
      }
    },
    {
      prop: 'overdueDay',
      label: '逾期天数'
    },
    {
      prop: 'returnedRemark',
      label: '备注'
    }
  ]
}

// 发票记录
export const invoiceColumns = ctx => {
  return [
    {
      prop: 'makeTime',
      label: '开票日期',
      minWidth: 120
    },
    {
      // prop: 'recycleName',
      label: '发票状态',
      render: (h, row) => {
        const style =
          row.isRecycle === '1'
            ? 'success'
            : row.isRecycle === '2'
              ? 'danger'
              : ''
        /* const list = getBaseData()
        const res = list.recycleStatus.find(item => {
          return item.value === row.isRecycle
        }) */
        return (
          <el-tag type={style} size="mini">
            {row.recycleName}
          </el-tag>
        )
      }
    },
    {
      prop: 'amount',
      label: '开票金额'
    },
    {
      prop: 'invoiceTypeName',
      label: '票据类型'
    },
    {
      prop: 'invoiceNumber',
      label: '发票号码'
    },
    {
      prop: 'invoiceCoding',
      label: '发票代码'
    },
    {
      prop: 'operator',
      label: '开票操作人'
    },
    {
      prop: 'updateTime',
      label: '录入时间'
    },
    {
      prop: 'billRemark',
      label: '发票内容'
    }
  ]
}
